package com.rritw.webtools.common;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/**
 * @author ZHANGYAN
 */
@Component
public class GlobalConfig {

    private static Map<String, String> configMap;

    @Resource
    private Properties                 configProperties;

    @SuppressWarnings("unused")
    @PostConstruct
    private void init() {
        configMap = new HashMap<String, String>();
        Set<Object> keys = configProperties.keySet();
        for (Object key : keys) {
            configMap.put(key.toString(), configProperties.getProperty(key.toString()));
        }
    }

    public String get(String key) {
        return configMap.get(key);
    }

    /**
     * 获取配置项的值
     * 
     * @param key
     * @return
     */
    public static String getConfig(String key) {
        return configMap.get(key);
    }
}
